package com.hanlin.beforejavacodesummary.pojo.po;

import lombok.Data;

/**
 * Created by IntelliJ IDEA.
 *
 * @author: lijing
 * @since: 2025-08-16
 * @description: 自然比较前提：    实现 Comparable<Person> 接口 重写 compareTo 方法
 */
@Data
public class PersonDO implements Comparable<PersonDO>{
    private String name;
    private int age;
    private String department;

    public PersonDO() {
    }

    public PersonDO(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public PersonDO(String name, int age, String department) {
        this.name = name;
        this.age = age;
        this.department = department;
    }

    @Override
    public int compareTo(PersonDO other) {
        // 自然排序：按姓名字典序  方法返回一个整数：负数表示当前对象小于参数对象，零表示相等，正数表示当前对象大于参数对象
        return this.name.compareTo(other.name);
    }
}
